#include <stdio.h>
#include "System.h"

/// <summary>
/// Retrieves a handle
/// for the runtime module.
/// </summary>
void *GetRuntimeHandle()
{
	void *handle;

	//if (!(handle = dlopen(NULL, RTLD_GLOBAL)))
	//	return NULL;

	return handle;
}

/// <summary>
/// Retrieves the fully-qualified
/// path for the file containing the
/// specified module.
/// </summary>
int GetRuntimeFile(wchar_t *path, size_t len)
{
	PID pid;
	char link[256];
	char data[PATH_MAX];

	if (path == NULL)
		return -1;

	if ((pid = GetProcessID()) < 1)
		return -2;

	sprintf(link, "/proc/%d/exe", pid);

	if (readlink(link, data, PATH_MAX) == -1)
		return -2;

	if (mbstowcs(path, data, len) < 0)
		return -2;

	return 0;
}

/// <summary>
/// Retrieves the fully-qualified
/// path for the file containing the
/// specified module.
/// </summary>
int GetRuntimePath(char *path, size_t len)
{
	return 0;
}
